package com.example.project.mapper;

import java.util.List;

import org.apache.ibatis.annotations.*;

import com.example.project.entity.TimeActivitie;

/**
 * 时间活动Mapper接口
 * 
 * @author ruoyi
 * @date 2025-11-17
 */
@Mapper
public interface TimeActivitieMapper {

	/**
	 * 查询时间活动
	 * 
	 * @param id 时间活动主键
	 * @return 时间活动
	 */
	@Select("select id, name, status, del_flag, create_by, create_time, update_by, update_time from t_time_activitie where id = #{id}")
	public TimeActivitie selectTimeActivitieById(Long id);

	/**
	 * 查询时间活动列表
	 * 
	 * @param timeActivitie 时间活动
	 * @return 时间活动集合
	 */
	@Select({"<script>",
		"select id, name, status, del_flag, create_by, create_time, update_by, update_time from t_time_activitie",
		"<where>",
		"<if test=\"name != null and name != ''\"> and name like concat('%', #{name}, '%')</if>",
		"<if test=\"status != null\"> and status = #{status}</if>",
		"</where>",
		"</script>"
	})
	public List<TimeActivitie> selectTimeActivitieList(TimeActivitie timeActivitie);

	/**
	 * 新增时间活动
	 * 
	 * @param timeActivitie 时间活动
	 * @return 结果
	 */
	@Insert({"<script>",
		"insert into t_time_activitie",
		"<trim prefix=\"(\" suffix=\")\" suffixOverrides=\",\">",
		"<if test=\"name != null\">name,</if>",
		"<if test=\"status != null\">status,</if>",
		"<if test=\"delFlag != null\">del_flag,</if>",
		"<if test=\"createBy != null\">create_by,</if>",
		"<if test=\"createTime != null\">create_time,</if>",
		"<if test=\"updateBy != null\">update_by,</if>",
		"<if test=\"updateTime != null\">update_time,</if>",
		"</trim>",
		"<trim prefix=\"values (\" suffix=\")\" suffixOverrides=\",\">",
		"<if test=\"name != null\">#{name},</if>",
		"<if test=\"status != null\">#{status},</if>",
		"<if test=\"delFlag != null\">#{delFlag},</if>",
		"<if test=\"createBy != null\">#{createBy},</if>",
		"<if test=\"createTime != null\">#{createTime},</if>",
		"<if test=\"updateBy != null\">#{updateBy},</if>",
		"<if test=\"updateTime != null\">#{updateTime},</if>",
		"</trim>",
		"</script>"
	})
	@Options(useGeneratedKeys = true, keyProperty = "id")
	public int insertTimeActivitie(TimeActivitie timeActivitie);

	/**
	 * 修改时间活动
	 * 
	 * @param timeActivitie 时间活动
	 * @return 结果
	 */
	@Update({"<script>",
		"update t_time_activitie",
		"<trim prefix=\"SET\" suffixOverrides=\",\">",
		"<if test=\"name != null\">name = #{name},</if>",
		"<if test=\"status != null\">status = #{status},</if>",
		"<if test=\"delFlag != null\">del_flag = #{delFlag},</if>",
		"<if test=\"createBy != null\">create_by = #{createBy},</if>",
		"<if test=\"createTime != null\">create_time = #{createTime},</if>",
		"<if test=\"updateBy != null\">update_by = #{updateBy},</if>",
		"<if test=\"updateTime != null\">update_time = #{updateTime},</if>",
		"</trim>",
		"where id = #{id}",
		"</script>"
	})
	public int updateTimeActivitie(TimeActivitie timeActivitie);

	/**
	 * 删除时间活动
	 * 
	 * @param id 时间活动主键
	 * @return 结果
	 */
//	@Delete("delete from t_time_activitie where id = #{id}")
	@Update("update t_time_activitie set del_flag = 1, update_time = NOW() where id = #{id}")
	public int deleteTimeActivitieById(Long id);

	/**
	 * 批量删除时间活动
	 * 
	 * @param ids 需要删除的数据主键集合
	 * @return 结果
	 */
//	@Delete({"<script>",
//		"delete from t_time_activitie where id in",
//		"<foreach item=\"id\" collection=\"array\" open=\"(\" separator=\",\" close=\")\">",
//		"#{id}",
//		"</foreach>",
//		"</script>"
//	})
	@Update("<script>" + "update t_time_activitie set del_flag = 1, update_time = NOW() where id in "
			+ "<foreach item='id' collection='array' open='(' separator=',' close=')'>" + "#{id}" + "</foreach>"
			+ "</script>")
	public int deleteTimeActivitieByIds(String[] ids);
}
